(function($){
	
    $(function(){
    	
    	//发布活动对话框
        $('#publishActive').dialog({
            autoOpen: false,
            height: 300,
            width: 560,
            modal: true,
            buttons: {
                '发布': function(){
                    $('#viewFragment').dialog('open');
                },
                '取消': function(){
                    $(this).dialog('close');
                }
            }
        });
        
        //发布活动链接
        $('.publish-active-link').click(function(e){
            e.preventDefault();
            showTips('活动发布成功！');
        });
        
        //充值
        $('#rechargeGold').dialog({
            autoOpen: false,
            height: 300,
            width: 420,
            modal: true,
            buttons: {
                '确定充值': function(){
                    alert('充值');
                },
                '取消': function(){
                    $(this).dialog('close');
                }
            }
        });
        
        //充值链接
        $('.recharge-gold-link').click(function(e){
            e.preventDefault();
            $('#rechargeGold').dialog('open');
        });
        
		//查看碎片
        $('#viewFragment').dialog({
            autoOpen: false,
            height: 600,
            width: 950,
            modal: true,
            buttons: {
                '确定': function(){
                    $(this).dialog('close');
                }
            }
        });
        
        //查看碎片链接
        $('.view-fragment-link').click(function(e){
            e.preventDefault();
            $('#viewFragment').find('textarea').each(function (i) {
            	$(this).val($.trim($(this).val()));
            });
            $('#viewFragment').dialog('open');
        });
        
        //查看碎片复制
        $('#viewFragment').find('.item').find('button').click(function () {
        	var $textarea = $(this).siblings('textarea');
        	copyTxt($textarea);
        })
        
		//活动开关
		$('.active-close').toggle(
			function() {
				$(this).text('开启');
				$(this).addClass('purple');
			},
			function() {
				$(this).text('关闭');
				$(this).removeClass('purple');
			}
		)
    	
    })

})(jQuery);